﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EasyTrader.Chart
{
    public partial class CPSvrNew7221KospiChartFrm : System.Windows.Forms.Form
    {
        private EasyTrader.Signal.TotalSignalManager m_GSignalManager = null;
        public EasyTrader.Signal.TotalSignalManager GSignalManager
        {
            get { return m_GSignalManager; }
            set { m_GSignalManager = value; }
        }

        public CPSvrNew7221KospiChartFrm()
        {
            InitializeComponent();
        }

        private void InitControl()
        {
            cbPerson.Checked = true;
            cbForeign.Checked = true;
            cbOrgan.Checked = true;
            cbInvest.Checked = false;
            cbPension.Checked = false;
            cbNation.Checked = false;
            cbFore.Checked = true;

            CPSvrNew7221KospiChartCtrl.Series["투신"].Enabled = false;
            CPSvrNew7221KospiChartCtrl.Series["연기금"].Enabled = false;
            CPSvrNew7221KospiChartCtrl.Series["국가"].Enabled = false;


            CPSvrNew7221KospiChartCtrl.Series["개인"].ToolTip = "#VALX : #VAL";
            CPSvrNew7221KospiChartCtrl.Series["외국인"].ToolTip = "#VALX : #VAL";
            CPSvrNew7221KospiChartCtrl.Series["기관계"].ToolTip = "#VALX : #VAL";
            CPSvrNew7221KospiChartCtrl.Series["투신"].ToolTip = "#VALX : #VAL";
            CPSvrNew7221KospiChartCtrl.Series["연기금"].ToolTip = "#VALX : #VAL";
            CPSvrNew7221KospiChartCtrl.Series["국가"].ToolTip = "#VALX : #VAL";

            CPSvrNew7221KospiChartCtrl.Series["개인예상가"].ToolTip = "#VALX : #VAL";
            CPSvrNew7221KospiChartCtrl.Series["외국인예상가"].ToolTip = "#VALX : #VAL";
            CPSvrNew7221KospiChartCtrl.Series["기관계예상가"].ToolTip = "#VALX : #VAL";
        }

        private void cbPerson_CheckedChanged(object sender, EventArgs e)
        {
            if (cbPerson.Checked)
            {
                CPSvrNew7221KospiChartCtrl.Series["개인"].Enabled = true;
            }
            else
            {
                CPSvrNew7221KospiChartCtrl.Series["개인"].Enabled = false;
            }
        }

        private void cbForeign_CheckedChanged(object sender, EventArgs e)
        {
            if (cbForeign.Checked)
            {
                CPSvrNew7221KospiChartCtrl.Series["외국인"].Enabled = true;
            }
            else
            {
                CPSvrNew7221KospiChartCtrl.Series["외국인"].Enabled = false;
            }
        }

        private void cbOrgan_CheckedChanged(object sender, EventArgs e)
        {
            if (cbOrgan.Checked)
            {
                CPSvrNew7221KospiChartCtrl.Series["기관계"].Enabled = true;
            }
            else
            {
                CPSvrNew7221KospiChartCtrl.Series["기관계"].Enabled = false;
            }
        }

        private void cbInvest_CheckedChanged(object sender, EventArgs e)
        {
            if (cbInvest.Checked)
            {
                CPSvrNew7221KospiChartCtrl.Series["투신"].Enabled = true;
            }
            else
            {
                CPSvrNew7221KospiChartCtrl.Series["투신"].Enabled = false;
            }
        }

        private void cbPension_CheckedChanged(object sender, EventArgs e)
        {
            if (cbPension.Checked)
            {
                CPSvrNew7221KospiChartCtrl.Series["연기금"].Enabled = true;
            }
            else
            {
                CPSvrNew7221KospiChartCtrl.Series["연기금"].Enabled = false;
            }
        }

        private void cbNation_CheckedChanged(object sender, EventArgs e)
        {
            if (cbNation.Checked)
            {
                CPSvrNew7221KospiChartCtrl.Series["국가"].Enabled = true;
            }
            else
            {
                CPSvrNew7221KospiChartCtrl.Series["국가"].Enabled = false;
            }
        }

        // Cybos Plus Data Set Member
        private ETDataSet m_CPDataSet = null;
        public EasyTrader.ETDataSet CPDataSet
        {
            get { return m_CPDataSet; }
            set { m_CPDataSet = value; }
        }
        private System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
        private void InitTimer()
        {
            timer.Interval = GlobalVar.ChartRefreshInterval;
            timer.Tick += new EventHandler(OnTimerTick);
            timer.Start();
        }

        // 여기서 차트를 갱신해 준다.
        private void OnTimerTick(object sender, EventArgs e)
        {
            // 차트에 데이터를 대응시켜 준다.
            if (GlobalVar.OperationMode == GlobalVar.OperationModeNormal)
            {
                SetChartData();
                ShowCurValue();
            }
            else
            {
                SetChartData(GlobalVar.SimulIndex);
                ShowCurValue(GlobalVar.SimulIndex);
            }
            SetForecastingYOnChart();
        }

        private void SetForecastingYOnChart()
        {
            if (m_GSignalManager == null)
                return;


            EasyTrader.Signal.ForecastingInfo foreInfo = GSignalManager.KospiPersonInfo;
            if (CPSvrNew7221KospiChartCtrl.Series["개인예상가"] != null && foreInfo != null)
            {
                CPSvrNew7221KospiChartCtrl.Series["개인예상가"].Points.Clear();
                CPSvrNew7221KospiChartCtrl.Series["개인예상가"].Points.AddXY(foreInfo.StartX, foreInfo.StartY / 100);
                CPSvrNew7221KospiChartCtrl.Series["개인예상가"].Points.AddXY(foreInfo.EndX, foreInfo.EndY / 100);
                txtPersonAngle.Text = "개인각도 : " + foreInfo.Angle.ToString("F2");
            }

            foreInfo = GSignalManager.KospiForeignInfo;
            if (CPSvrNew7221KospiChartCtrl.Series["외국인예상가"] != null && foreInfo != null)
            {
                CPSvrNew7221KospiChartCtrl.Series["외국인예상가"].Points.Clear();
                CPSvrNew7221KospiChartCtrl.Series["외국인예상가"].Points.AddXY(foreInfo.StartX, foreInfo.StartY / 100);
                CPSvrNew7221KospiChartCtrl.Series["외국인예상가"].Points.AddXY(foreInfo.EndX, foreInfo.EndY / 100);
                txtForeignAngle.Text = "외국인각도 : " + foreInfo.Angle.ToString("F2");
            }

            foreInfo = GSignalManager.KospiOrganInfo;
            if (CPSvrNew7221KospiChartCtrl.Series["기관계예상가"] != null && foreInfo != null)
            {
                CPSvrNew7221KospiChartCtrl.Series["기관계예상가"].Points.Clear();
                CPSvrNew7221KospiChartCtrl.Series["기관계예상가"].Points.AddXY(foreInfo.StartX, foreInfo.StartY / 100);
                CPSvrNew7221KospiChartCtrl.Series["기관계예상가"].Points.AddXY(foreInfo.EndX, foreInfo.EndY / 100);
                txtOrganAngle.Text = "기관각도 : " + foreInfo.Angle.ToString("F2");
            }
        }

        private void ShowCurValue()
        {
            // 데이터 셋 객체가 없으면 아무일도 하지 않는다.
            if (m_CPDataSet == null || GlobalVar.CPSvrNew7221DataDownloaded == false)
                return;

            CPSvrNew7221Table dataTable = m_CPDataSet.GetCPSvrNew7221Table();
            int rowCount = dataTable.GetRowCount();
            if (rowCount == 0)
                return;

            DataRow row = dataTable.Rows[rowCount - 1];
            if (row["코스피개인순매수"] == DBNull.Value)
                return;

            double personVal = Convert.ToDouble(row["코스피개인순매수"]) / 100;
            double foreignVal = Convert.ToDouble(row["코스피외국인순매수"]) / 100;
            double organVal = Convert.ToDouble(row["코스피기관계순매수"]) / 100;
            string curTime = row["시각"].ToString();
            if (curTime != "0")
            {
                string minText = curTime.Substring(curTime.Length - 2, 2);
                string hourText = curTime.Substring(0, curTime.Length - 2);

                txtCurTime.Text = "현재시간 " + hourText + " : " + minText;
                txtCurPrice.Text = "개인순매수 : " + personVal.ToString("F2") + ", 외국인순매수 : " + foreignVal.ToString("F2") + "  기관순매수 : " + organVal.ToString("F2");
            }
        }

        private void ShowCurValue(int a_CurIndex)
        {
            // 데이터 셋 객체가 없으면 아무일도 하지 않는다.
            if (m_CPDataSet == null)
                return;

            CPSvrNew7221Table dataTable = m_CPDataSet.GetCPSvrNew7221Table();
            int rowCount = dataTable.GetRowCount();
            if (rowCount == 0)
                return;
            if (rowCount - 1 < a_CurIndex)
                return;

            DataRow row = dataTable.Rows[a_CurIndex];
            if (row["코스피개인순매수"] == DBNull.Value)
                return;

            double personVal = Convert.ToDouble(row["코스피개인순매수"]) / 100;
            double foreignVal = Convert.ToDouble(row["코스피외국인순매수"]) / 100;
            double organVal = Convert.ToDouble(row["코스피기관계순매수"]) / 100;
            string curTime = row["시각"].ToString();
            if (curTime != "0")
            {
                string minText = curTime.Substring(curTime.Length - 2, 2);
                string hourText = curTime.Substring(0, curTime.Length - 2);

                txtCurTime.Text = "현재시간 " + hourText + " : " + minText;
                txtCurPrice.Text = "개인순매수 : " + personVal.ToString("F2") + ", 외국인순매수 : " + foreignVal.ToString("F2") + "  기관순매수 : " + organVal.ToString("F2");
            }
        }

        private void SetChartData()
        {
            // 데이터 셋 객체가 없으면 아무일도 하지 않는다.
            if (m_CPDataSet == null)
                return;

            CPSvrNew7221KospiChartCtrl.Series["개인"].Points.Clear();
            CPSvrNew7221KospiChartCtrl.Series["외국인"].Points.Clear();
            CPSvrNew7221KospiChartCtrl.Series["기관계"].Points.Clear();
            CPSvrNew7221KospiChartCtrl.Series["투신"].Points.Clear();
            CPSvrNew7221KospiChartCtrl.Series["연기금"].Points.Clear();
            CPSvrNew7221KospiChartCtrl.Series["국가"].Points.Clear();
            CPSvrNew7221Table dataTable = m_CPDataSet.GetCPSvrNew7221Table();
            //double maxValue = -10000.0;
            //double minValue = 10000.0;
            int rowCount = dataTable.GetRowCount();
            if (rowCount == 0)
                return;

            //int minIndex = 0;
            //int maxIndex = 0;
            double personVal = 0;
            double foreignVal = 0;
            double organVal = 0;
            double investVal = 0;
            double pensionVal = 0;
            double nationVal = 0;
            for (int i = 0; i < rowCount; i++)
            {
                DataRow row = dataTable.Rows[i];
                try
                {
                    // 값이 없을 경우는 넘어 간다.
                    if (row["코스피개인순매수"] == DBNull.Value)
                        continue;

                    personVal = Convert.ToDouble(row["코스피개인순매수"]) / 100;
                    foreignVal = Convert.ToDouble(row["코스피외국인순매수"]) / 100;
                    organVal = Convert.ToDouble(row["코스피기관계순매수"]) / 100;
                    investVal = Convert.ToDouble(row["코스피투신순매수"]) / 100;
                    pensionVal = Convert.ToDouble(row["코스피연기금순매수"]) / 100;
                    nationVal = Convert.ToDouble(row["코스피국가순매수"]) / 100;
                    CPSvrNew7221KospiChartCtrl.Series["개인"].Points.AddXY(i, personVal);
                    CPSvrNew7221KospiChartCtrl.Series["외국인"].Points.AddXY(i, foreignVal);
                    CPSvrNew7221KospiChartCtrl.Series["기관계"].Points.AddXY(i, organVal);
                    CPSvrNew7221KospiChartCtrl.Series["투신"].Points.AddXY(i, investVal);
                    CPSvrNew7221KospiChartCtrl.Series["연기금"].Points.AddXY(i, pensionVal);
                    CPSvrNew7221KospiChartCtrl.Series["국가"].Points.AddXY(i, nationVal);
                    CPSvrNew7221KospiChartCtrl.Series["개인"].Points[i].XValue = i;
                    //CPSvrNew7221KospiChartCtrl.Series["개인"].Points[i].AxisLabel = row["시각"].ToString();
                    int hour = Convert.ToInt32(row["시각"]);
                    if (hour != 0)
                        CPSvrNew7221KospiChartCtrl.Series["개인"].Points[i].AxisLabel = row["시각"].ToString();
                    else
                        CPSvrNew7221KospiChartCtrl.Series["개인"].Points[i].AxisLabel = GlobalVar.DayIndexToTime(i).ToString();

                    
                    /*
                    if (personVal != 0 && personVal > maxValue)
                    {
                        maxValue = personVal;
                        maxIndex = i;
                    }

                    if (foreignValue != 0 && foreignValue > maxValue)
                    {
                        maxValue = foreignValue;
                        maxIndex = i;
                    }

                    if (foreignValue != 0 && foreignValue < minValue)
                    {
                        minValue = foreignValue;
                        minIndex = i;
                    }

                    if (personVal != 0 && personVal < minValue)
                    {
                        minValue = personVal;
                        minIndex = i;
                    }*/
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }

            /*
            int valueHeight = (int)(maxValue - minValue) / 500;
            maxValue = valueHeight * 500 + 500;

            if (maxValue >= minValue)
            {
                CPSvrNew7221KospiChartCtrl.ChartAreas["price"].AxisY.Minimum = minValue;
                CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisY.Maximum = maxValue;
            }*/
        }

        private void SetChartData(int a_CurIndex)
        {
            // 데이터 셋 객체가 없으면 아무일도 하지 않는다.
            if (m_CPDataSet == null)
                return;

            CPSvrNew7221KospiChartCtrl.Series["개인"].Points.Clear();
            CPSvrNew7221KospiChartCtrl.Series["외국인"].Points.Clear();
            CPSvrNew7221KospiChartCtrl.Series["기관계"].Points.Clear();
            CPSvrNew7221KospiChartCtrl.Series["투신"].Points.Clear();
            CPSvrNew7221KospiChartCtrl.Series["연기금"].Points.Clear();
            CPSvrNew7221KospiChartCtrl.Series["국가"].Points.Clear();
            CPSvrNew7221Table dataTable = m_CPDataSet.GetCPSvrNew7221Table();
            //double maxValue = -10000.0;
            //double minValue = 10000.0;
            int rowCount = dataTable.GetRowCount();
            if (rowCount == 0)
                return;
            if (rowCount - 1 < a_CurIndex)
                return;
            //int minIndex = 0;
            //int maxIndex = 0;
            double personVal = 0;
            double foreignVal = 0;
            double organVal = 0;
            double investVal = 0;
            double pensionVal = 0;
            double nationVal = 0;
            for (int i = 0; i <= a_CurIndex; i++)
            {
                DataRow row = dataTable.Rows[i];
                try
                {
                    // 값이 없을 경우는 넘어 간다.
                    if (row["코스피개인순매수"] == DBNull.Value)
                        continue;

                    personVal = Convert.ToDouble(row["코스피개인순매수"]) / 100;
                    foreignVal = Convert.ToDouble(row["코스피외국인순매수"]) / 100;
                    organVal = Convert.ToDouble(row["코스피기관계순매수"]) / 100;
                    investVal = Convert.ToDouble(row["코스피투신순매수"]) / 100;
                    pensionVal = Convert.ToDouble(row["코스피연기금순매수"]) / 100;
                    nationVal = Convert.ToDouble(row["코스피국가순매수"]) / 100;
                    CPSvrNew7221KospiChartCtrl.Series["개인"].Points.AddXY(i, personVal);
                    CPSvrNew7221KospiChartCtrl.Series["외국인"].Points.AddXY(i, foreignVal);
                    CPSvrNew7221KospiChartCtrl.Series["기관계"].Points.AddXY(i, organVal);
                    CPSvrNew7221KospiChartCtrl.Series["투신"].Points.AddXY(i, investVal);
                    CPSvrNew7221KospiChartCtrl.Series["연기금"].Points.AddXY(i, pensionVal);
                    CPSvrNew7221KospiChartCtrl.Series["국가"].Points.AddXY(i, nationVal);
                    CPSvrNew7221KospiChartCtrl.Series["개인"].Points[i].XValue = i;
                    //CPSvrNew7221KospiChartCtrl.Series["개인"].Points[i].AxisLabel = row["시각"].ToString();
                    int hour = Convert.ToInt32(row["시각"]);
                    if (hour != 0)
                        CPSvrNew7221KospiChartCtrl.Series["개인"].Points[i].AxisLabel = row["시각"].ToString();
                    else
                        CPSvrNew7221KospiChartCtrl.Series["개인"].Points[i].AxisLabel = GlobalVar.DayIndexToTime(i).ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }

        public CPSvrNew7221KospiChartFrm(ETDataSet a_DataSet)
        {
            InitializeComponent();
            m_CPDataSet = a_DataSet;
            InitControl();
        }

        private void InitChart()
        {
            CPSvrNew7221KospiChartCtrl.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(211)), ((System.Byte)(223)), ((System.Byte)(240)));
            CPSvrNew7221KospiChartCtrl.BackSecondaryColor = System.Drawing.Color.White;
            CPSvrNew7221KospiChartCtrl.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom;
            CPSvrNew7221KospiChartCtrl.BorderlineColor = System.Drawing.Color.FromArgb(((System.Byte)(26)), ((System.Byte)(59)), ((System.Byte)(105)));
            CPSvrNew7221KospiChartCtrl.BorderlineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid;
            CPSvrNew7221KospiChartCtrl.BorderlineWidth = 2;
            CPSvrNew7221KospiChartCtrl.BorderSkin.SkinStyle = System.Windows.Forms.DataVisualization.Charting.BorderSkinStyle.Emboss;

            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisX.MajorGrid.Interval = 10;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisX.Interval = 10;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisY.MajorGrid.Interval = 100000/100;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisY.MinorGrid.Interval = 50000/100;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisY.Interval = 50000/100;

            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].Area3DStyle.IsClustered = true;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].Area3DStyle.Perspective = 10;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].Area3DStyle.IsRightAngleAxes = false;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].Area3DStyle.WallWidth = 0;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].Area3DStyle.Inclination = 15;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].Area3DStyle.Rotation = 10;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisX.IsLabelAutoFit = true;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisX.LabelStyle.Font = new System.Drawing.Font("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Bold);
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisX.LabelStyle.IsEndLabelVisible = false;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisX.LineColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisX.MajorGrid.LineColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisY.IsLabelAutoFit = true;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisY.LabelStyle.Font = new System.Drawing.Font("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Bold);
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisY.LineColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisY.MajorGrid.LineColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisY.IsStartedFromZero = false;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisY.MinorGrid.LineColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisY.MinorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.DashDot;

            //CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisY.LabelAutoFitMaxFontSize;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].BackColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(165)), ((System.Byte)(191)), ((System.Byte)(228)));
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].BackSecondaryColor = System.Drawing.Color.White;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].BorderColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].BorderDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].Position.Auto = true;
            //CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].Position.Height = 80F;
            //CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].Position.Width = 80F;
            //CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].Position.X = 5F;
            //CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].Position.Y = 10F;
            CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].ShadowColor = System.Drawing.Color.Transparent;
            
            
            //CPSvrNew7221KospiChartCtrl.Series["지수"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
             

            //CPSvrNew7221KospiChartCtrl.Series[0]["PriceUpColor"] = "blue";
            //CPSvrNew7221KospiChartCtrl.Series[0]["PriceDownColor"] = "Red";
            //CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisX.LabelStyle.IsEndLabelVisible = true;
            //CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisX.IsMarginVisible = true;
            //CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisY.LabelStyle.IsEndLabelVisible = true;
            //CPSvrNew7221KospiChartCtrl.ChartAreas["Price"].AxisY.IsMarginVisible = true;
            //CPSvrNew7221KospiChartCtrl.Series[0].Color = Color.Red;
            //DataPointCustomProperties aa = CPSvrNew7221KospiChartCtrl.Series[0]["PriceUpColor"];
            System.Windows.Forms.DataVisualization.Charting.StripLine stripLine = new System.Windows.Forms.DataVisualization.Charting.StripLine();
            stripLine.Interval = 0;
            stripLine.IntervalOffset = 0;
            stripLine.BackColor = Color.Black;
            stripLine.StripWidth = 1.0;
            stripLine.Text = "기준선 : 0";
            stripLine.TextAlignment = StringAlignment.Near;
            CPSvrNew7221KospiChartCtrl.ChartAreas[0].AxisY.StripLines.Add(stripLine);
        }

        private void CPSvrNew7221KospiChart_Load(object sender, EventArgs e)
        {
            InitChart();
            InitTimer();
        }

        private void CPSvrNew7221KospiChart_FormClosing(object sender, FormClosingEventArgs e)
        {
            timer.Stop();
        }

        private void cbFore_CheckedChanged(object sender, EventArgs e)
        {
            if (cbFore.Checked)
            {
                CPSvrNew7221KospiChartCtrl.Series["개인예상가"].Enabled = true;
                CPSvrNew7221KospiChartCtrl.Series["외국인예상가"].Enabled = true;
                CPSvrNew7221KospiChartCtrl.Series["기관계예상가"].Enabled = true;
            }
            else
            {
                CPSvrNew7221KospiChartCtrl.Series["개인예상가"].Enabled = false;
                CPSvrNew7221KospiChartCtrl.Series["외국인예상가"].Enabled = false;
                CPSvrNew7221KospiChartCtrl.Series["기관계예상가"].Enabled = false;
            }
        }
    }
}
